package com.yjhealth.libs.businessdemo.business;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;

import com.yjhealth.libs.businessdemo.R;
import com.yjhealth.libs.commonlib.base.activity.BaseActivity;
import com.yjhealth.libs.core.toast.ToastUtil;
import com.yjhealth.libs.core.core.activity.CoreActivity;
import com.yjhealth.libs.core.utils.DateUtil;
import com.yjhealth.libs.core.view.dialog.CoreDatePickerDialog;

import java.util.Calendar;

public class DemoDatePickerActivity extends BaseActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.businessdemo_activity_demo_date_picker);

        Button btnPicker = findViewById(R.id.btnPicker);
        btnPicker.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Calendar calendar = Calendar.getInstance();
                int curYear = calendar.get(Calendar.YEAR);
                int curMonth = calendar.get(Calendar.MONTH);
                int curDay = calendar.get(Calendar.DAY_OF_MONTH);
                CoreDatePickerDialog.newInstance(curYear, curMonth, curDay)
                        .setMaxDate(DateUtil.getCurTime())
                        .setCommonDialogListener(new CoreDatePickerDialog.OnDateSetListener() {
                            @Override
                            public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                                ToastUtil.toast(year + ":" + monthOfYear + ":" + dayOfMonth);
                            }
                        }).show(getFragmentManager(),"");
            }
        });
    }

    @Override
    protected void onRefreshView() {

    }
}
